﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Denting
{
    public class Node
    {
        public int NodeID { get; set; }
        public double X_position { get; set; }
        public double Y_position { get; set; }
        public double Z_position { get; set; }
        public Node(int id, double X, double Y, double Z)
        {
            NodeID = id;
            X_position = X;
            Y_position = Y;
            Z_position = Z;
        }
        public Node() : this(0, 0, 0, 0) { }

        public void Show()
        {
            Console.WriteLine("NodeID:{0}", this.NodeID);
            Console.WriteLine("Node_X:{0}", this.X_position);
            Console.WriteLine("Node_Y:{0}", this.Y_position);
            Console.WriteLine("Node_Z:{0}", this.Z_position);
        }

        public Node Clone()
        {
            Node tempNode = new Node();
            tempNode.NodeID = this.NodeID;
            tempNode.X_position = this.X_position;
            tempNode.Y_position = this.Y_position;
            tempNode.Z_position = this.Z_position;
            return tempNode;
        }
        public Node RotateX(double angle)
        {
            double PI = 3.1415926535897932;
            angle = angle * PI / 180;
            Node nodeSource = this.Clone();
            this.X_position = nodeSource.X_position;
            this.Y_position = nodeSource.Y_position * Math.Cos(angle) - nodeSource.Z_position * Math.Sin(angle);
            this.Z_position = nodeSource.Z_position * Math.Cos(angle) + nodeSource.Y_position * Math.Sin(angle);

            return this;
        }
        public Node RotateY(double angle)
        {
            double PI = 3.1415926535897932;
            angle = angle * PI / 180;
            Node nodeSource = this.Clone();

            this.X_position = nodeSource.X_position * Math.Cos(angle) + nodeSource.Z_position * Math.Sin(angle);
            this.Y_position = nodeSource.Y_position;
            this.Z_position = nodeSource.Z_position * Math.Cos(angle) - nodeSource.X_position * Math.Sin(angle);

            return this;
        }

        public Node Trans(VectorXYZ v)
        {
            this.X_position += v.x;
            this.Y_position += v.y;
            this.Z_position += v.z;
            return this;
        }
    }
}
